"""
Created on 2017年8月2日

@author: xiaoj
"""


class UrlManager:
    def __init__(self):
        self.newurls = set()
        self.oldurls = set()

    def add_urls(self, urls):
        if urls:
            for url in urls:
                if url not in self.newurls and url not in self.oldurls:
                    self.newurls.add(url)

    def add_url(self, url):
        if url:
            self.newurls.add(url)

    def get_new_url(self):
        new_url = self.newurls.pop()
        self.oldurls.add(new_url)
        return new_url

    def has_next(self):
        return len(self.newurls) != 0